var __extends =
    (this && this.__extends) ||
    (function () {
      var i = function (t, e) {
        return (i =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (i, t) {
              i.__proto__ = t;
            }) ||
          function (i, t) {
            for (var e in t)
              Object.prototype.hasOwnProperty.call(t, e) && (i[e] = t[e]);
          })(t, e);
      };
      return function (t, e) {
        function o() {
          this.constructor = t;
        }
        if ("function" != typeof e && null !== e)
          throw new TypeError(
            "Class extends value " + String(e) + " is not a constructor or null"
          );
        i(t, e),
          (t.prototype =
            null === e
              ? Object.create(e)
              : ((o.prototype = e.prototype), new o()));
      };
    })(),
  AXConfuciusInstituteView = (function (i) {
    function t() {
      var t = i.call(this) || this;
      return (
        t.btn_confucius_cancle.on(Laya.Event.CLICK, t, t.onConfuciusCancle),
        t.tab_confuciusinstutute.on(
          Laya.Event.CLICK,
          t,
          t.onTabConfuciusDidClickFn
        ),
        t.btn_kongmiao_zhaotu.on(Laya.Event.CLICK, t, t.onDidKongMiaoAction),
        t.btn_kongmiao_baishi.on(Laya.Event.CLICK, t, t.onDidKongMiaoAction),
        t.btn_kongmiao_shuoming.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickKongMiaoShuoMing
        ),
        (t.list_main_kongmiao.vScrollBarSkin = ""),
        (t.list_main_kongmiao.selectEnable = !0),
        t.list_main_kongmiao.on(Laya.Event.CLICK, t, t.onDidListClickAction),
        (t.list_main_kongmiao.renderHandler = new Handler(t, t.onUpdateItem)),
        t.list_tudiliebiao.on(Laya.Event.CLICK, t, t.onDidTuDiListAction),
        t.btn_shifu_jiechu.on(Laya.Event.CLICK, t, t.onDidShiFuItemAction),
        WebSocketService.addListener({
          caller: t,
          code: 1334,
          method: t.onLoadHomeFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1347,
          method: t.onLoadMainData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1377,
          method: t.onLoadMainTuDiList,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1379,
          method: t.onLoadKongMiaoResultData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1036,
          method: t.onLoadShiTuServiceData,
        }),
        t
      );
    }
    return (
      __extends(t, i),
      (t.openView = function () {
        return (
          null == this.confuciusVC && (this.confuciusVC = new t()),
          WebSocketService.send({ c: 1347, d: { t: 1 } }),
          (this.confuciusVC.tab_confuciusinstutute.selectedIndex = 0),
          this.confuciusVC.initUI(),
          this.confuciusVC
        );
      }),
      (t.prototype.initUI = function () {
        (this.label_shifu_name.visible = !1),
          (this.label_shifu_lvl.visible = !1),
          (this.btn_shifu_jiechu.visible = !1),
          (this.label_shifu_tip.visible = !1),
          (this.label_tudi_tip.visible = !1),
          (this.list_main_kongmiao.visible = !0),
          (this.list_tudiliebiao.visible = !1),
          (this.dataArr = []),
          (this.tab_type = "招徒贴");
      }),
      (t.prototype.onLoadHomeFn = function (i) {
        if (0 == i.code)
          if (i.data && i.data.id > 0) {
            (this.shifuObj = i.data),
              (this.label_shifu_name.visible = !0),
              (this.label_shifu_lvl.visible = !0),
              (this.btn_shifu_jiechu.visible = !0),
              (this.label_shifu_name.color = "#f30804");
            var t = Utils.transform(i.data.roleType, "roleType");
            (this.label_shifu_name.text = i.data.name),
              (this.label_shifu_lvl.text = t + i.data.lvl);
          } else
            (this.label_shifu_name.visible = !0),
              (this.label_shifu_lvl.visible = !1),
              (this.btn_shifu_jiechu.visible = !1),
              (this.label_shifu_name.color = "#f3e904"),
              (this.label_shifu_name.text = "暂无"),
              (this.label_shifu_lvl.text = "");
      }),
      (t.prototype.onDidKongMiaoAction = function (i) {
        if ("item0" == i.target.name) {
          t = { title: "招徒贴" };
          KongMiaoDialog.showKongMiaoDialog(t);
        } else if ("item1" == i.target.name) {
          var t = { title: "拜师贴" };
          KongMiaoDialog.showKongMiaoDialog(t);
        }
      }),
      (t.prototype.onLoadMainData = function (i) {
        if (0 == i.code) {
          (this.dataArr = []), void 0 != i.list && (this.dataArr = i.list);
          for (var t, e = [], o = 0; o < this.dataArr.length; o++) {
            var n = this.dataArr[o],
              a = Utils.transform(n.roleType, "roleType");
            (t = {
              item_kongmiao_name: { text: n.name },
              item_kongmiao_zhiye: { text: n.lvl + "级" + a },
              item_kongmiao_desc: { text: n.content },
              id: n.id,
              lvl: n.lvl,
              name: n.name,
              userId: n.userId,
            }),
              e.push(t);
          }
          this.list_main_kongmiao.array = e;
        } else ToastView.toastView(i.msg);
      }),
      (t.prototype.onTabConfuciusDidClickFn = function (i) {
        (this.label_shifu_name.visible = !1),
          (this.label_shifu_lvl.visible = !1),
          (this.btn_shifu_jiechu.visible = !1),
          (this.label_shifu_tip.visible = !1),
          (this.label_tudi_tip.visible = !1),
          "item0" == i.target.name
            ? ((this.tab_type = "招徒贴"),
              WebSocketService.send({ c: 1347, d: { t: 1 } }),
              (this.list_main_kongmiao.visible = !0),
              (this.list_tudiliebiao.visible = !1))
            : "item1" == i.target.name
            ? ((this.tab_type = "拜师贴"),
              WebSocketService.send({ c: 1347, d: { t: 0 } }),
              (this.list_main_kongmiao.visible = !0),
              (this.list_tudiliebiao.visible = !1))
            : "item2" == i.target.name &&
              ((this.tab_type = "徒弟列表"),
              WebSocketService.send({ c: 1377 }),
              WebSocketService.send({ c: 1334, d: null }),
              (this.list_main_kongmiao.visible = !1),
              (this.list_tudiliebiao.visible = !0),
              (this.label_shifu_tip.visible = !0),
              (this.label_tudi_tip.visible = !0));
      }),
      (t.prototype.onUpdateItem = function (i, t) {
        var e = i.getChildByName("btn_kongmiao");
        "招徒贴" == this.tab_type
          ? (e.label = "拜师")
          : "拜师贴" == this.tab_type && (e.label = "招徒");
      }),
      (t.prototype.onDidListClickAction = function (i) {
        if ("" != i.target.name && "btn_kongmiao" == i.target.name) {
          var t = this.list_main_kongmiao.selectedItem;
          "拜师贴" == this.tab_type
            ? NormalDialog.showNormalDialog(
                "您确定要招 " + t.name + " 为徒吗",
                this,
                this.onSureBaiShi
              )
            : "招徒贴" == this.tab_type &&
              NormalDialog.showNormalDialog(
                "您确定要拜 " + t.name + " 为师吗",
                this,
                this.onSureZhaoTu
              );
        }
      }),
      (t.prototype.onSureBaiShi = function () {
        var i = this.list_main_kongmiao.selectedItem;
        WebSocketService.send({ c: 1379, d: { id: i.userId, t: 0 } });
      }),
      (t.prototype.onSureZhaoTu = function () {
        var i = this.list_main_kongmiao.selectedItem;
        WebSocketService.send({ c: 1379, d: { id: i.userId, t: 1 } });
      }),
      (t.prototype.onLoadKongMiaoResultData = function (i) {
        ToastView.toastView(i.msg);
      }),
      (t.prototype.onLoadMainTuDiList = function (i) {
        if (0 == i.code) {
          for (var t, e = i.data, o = [], n = 0; n < e.length; n++) {
            var a = e[n],
              s = Utils.transform(a.type, "roleType"),
              l = Utils.transform(1 - a.sex, "roleSexType");
            (t = {
              item_tudi_name: { text: a.name },
              item_tudi_lvl: { text: a.lvl + "级 " + l + s },
              id: a.id,
              name: a.name,
            }),
              o.push(t);
          }
          this.list_tudiliebiao.array = o;
        } else ToastView.toastView(i.msg);
      }),
      (t.prototype.onDidTuDiListAction = function (i) {
        if ("" != i.target.name && "btn_tudi_jiechu" == i.target.name) {
          var t = this.list_tudiliebiao.selectedItem;
          NormalDialog.showNormalDialog(
            "您确定要与" + t.name + "解除师徒关系吗？",
            this,
            this.onSureJieChuTuDiAction
          );
        }
      }),
      (t.prototype.onSureJieChuTuDiAction = function () {
        var i = this.list_tudiliebiao.selectedItem;
        WebSocketService.send({ c: 1036, d: { id: i.id, t: 2 } });
      }),
      (t.prototype.onDidShiFuItemAction = function () {
        NormalDialog.showNormalDialog(
          "您确定要与" + this.shifuObj.name + "解除师徒关系吗？",
          this,
          this.onSureJieChuShiFuAction
        );
      }),
      (t.prototype.onSureJieChuShiFuAction = function () {
        WebSocketService.send({ c: 1036, d: { id: this.shifuObj.id, t: 1 } });
      }),
      (t.prototype.onLoadShiTuServiceData = function (i) {
        0 == i.code &&
          (ToastView.toastView(i.msg),
          WebSocketService.send({ c: 1377 }),
          WebSocketService.send({ c: 1334, d: null }));
      }),
      (t.prototype.onDidClickKongMiaoShuoMing = function () {
        var i = RulesView.showCaslRuleView("kongmiaoshuoming");
        (i.y = 0), Laya.stage.addChild(i);
      }),
      (t.prototype.onConfuciusCancle = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.SubSquareController.AXConfuciusInstituteViewUI);
